package main

import (
	"file-jet/file"
	"file-jet/rsync"
	"flag"
	"os"

	"github.com/sirupsen/logrus"
)

// -ad "${ad}" -fn "${fn}" -sn "${sn}" -fb "${fb}" -st "${st}" -fpn "${fpn}"
var (
	addr        = flag.String("ad", "ip", "are you ok")
	fileName    = flag.String("fn", "", "filename")
	subname     = flag.String("sn", "", "subname")
	frontorback = flag.String("fb", "frontorback", "frontorback")
	starget     = flag.String("st", "", "source target")
	fpn         = flag.String("fpn", "", "fpn")
	cmd         = flag.String("cmd", "", "run cmd")
	dtarget     = flag.String("dt", "", "dtarget")
	run         = flag.String("run", "", "startweb")
)

func main() {
	logger := logrus.New()
	logger.SetLevel(logrus.InfoLevel)
	logger.SetOutput(os.Stdout)
	logger.SetFormatter(&logrus.JSONFormatter{
		TimestampFormat: "2006-01-02 15:04:05",
	})
	flag.Parse()
	var files file.Fileput
	files.Address = *addr
	files.Filename = *fileName
	files.Subname = *subname
	files.FrontOrBack = *frontorback
	files.FilePutName = *fpn
	files.Command = *cmd
	files.Starget = *starget
	files.DTarget = *dtarget
	switch *run {
	case "web":
		rsync.Rsyncserv(files, logger)
	default:
		rsync.Rsynccli(files, logger)
	}
}
